<?php
ptaste();
require_once(dirname(__FILE__)."/interfaces.php");


class JEngXSLT implements IJXmlProducer
{
  public $xsl=null;
  public $xml=null;
  public $proc=null;
  
  function __construct($xml,$xsl)
  {
    $this->xml=$xml;
	$this->xsl=$xsl;
	$this->proc=new XSLTProcessor;
  }
  
  function prepare()
  {
  }
  
  function render()
  {
    $this->prepare();
	$this->proc->importStyleSheet($this->xsl);
	$doc=$this->proc->transformToDoc($this->xml);
	$doc->encoding="utf8";
	return $doc;
  }
  
  static function s_render()
  {
    $xml=func_get_arg(0);
	$xsl=func_get_arg(1);
    $obj=new JEngXSLT($xml,$xsl);
	return $obj->render();
  }
}

class JEngXSLTXmlFile extends JEngXSLT
{
 function __construct($xml,$xsl)
  {
	$xxml=new DOMDocument;
	$xxml->load($xml);
	parent::__construct($xxml,$xsl);
  }
  
  static function s_render()
  {
    $xml=func_get_arg(0);
	$xsl=func_get_arg(1);
    $obj=new JEngXSLTXmlFile($xml,$xsl);
	return $obj->render();
  }
}

class JEngXSLTXslFile extends JEngXSLT
{
  function __construct($xml,$xsl)
  {
	$xxsl=new DOMDocument;
	$xxsl->load($xsl);
	parent::__construct($xml,$xxsl);
  }
  
  static function s_render()
  {
    $xml=func_get_arg(0);
	$xsl=func_get_arg(1);
    $obj=new JEngXSLTXslFile($xml,$xsl);
	return $obj->render();
  }
}


class JEngXSLTFiles extends JEngXSLT
{
  function __construct($xml,$xsl)
  {
	$xxml=new DOMDocument;
	$xxsl=new DOMDocument;
	$xxml->load($xml);
	$xxsl->load($xsl);
	parent::__construct($xxml,$xxsl);
  }
  
  static function s_render()
  {
    $xml=func_get_arg(0);
	$xsl=func_get_arg(1);
    $obj=new JEngXSLTFiles($xml,$xsl);
	return $obj->render();
  }
}


?>